package com.voicechat.firstmet.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bumptech.glide.Glide;
import com.voicechat.firstmet.R;
import com.voicechat.firstmet.base.BaseAdapter;
import com.voicechat.firstmet.view.CircleImageView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.adapter
 * @ClassName: 社区图片adapter
 * @Description: java类作用描述
 * @Author: ljp
 * @CreateDate: 2018/9/4 14:11
 * @Version: 1.0
 */
public class PhotoPictureAdapter extends BaseAdapter<String>{
    private Context context;
    private  List<String>  tlist;
    int number = 0;
    Thread thread;
    private OnClick onClick;

    public void setOnClick(OnClick onClick) {
        this.onClick = onClick;
    }

    /**
     * @param context activity_imessage
     * @param icons
     * @param mLayout 主布局
     */
    public PhotoPictureAdapter(Context context, List<String> icons, int mLayout) {
        super(context, icons, mLayout);
        this.context = context;
        this.tlist = icons;
    }

    @Override
    protected RecyclerView.ViewHolder getHeaderViewHolder(View view) {
        return null;
    }

    @Override
    protected RecyclerView.ViewHolder getItemViewHolder(View view) {
        ViewHolder1 viewHolder1 = new ViewHolder1(view);

        return viewHolder1;
    }

    @Override
    protected RecyclerView.ViewHolder getFooterViewHolder(View view) {
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
       if(viewHolder instanceof ViewHolder1){
           Glide.with(context).load(tlist.get(position)).into(((ViewHolder1) viewHolder).imageIcon);
           ((ViewHolder1) viewHolder).imageIcon.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                   onClick.onSetPictureClick(((ViewHolder1) viewHolder).imageIcon,position);
               }
           });
        }
    }

    /**
     * 布局1
     */
    class ViewHolder1 extends BaseViewHolder{
        @BindView(R.id.circle_picture)
        CircleImageView imageIcon;
        public ViewHolder1(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    public  interface OnClick{
        void onSetPictureClick(View view, int position);
    }
}
